//variables to move the planet
int tx, ty; 
int Sty;

//a function to set up the general drawing parameters
void setup() {
  size(400, 300);
  background(#579D5F);
  smooth();
  tx = 400;
  ty = 100;
  Sty = 300;
  frameRate(30);
}

//press any key to reset the planet
void keyPressed() {
  tx = 400;
  ty = 100;
  Sty = 300;
}

//function to draw the planet
void drawPlanet() {
  fill(#E8E8C2);
  stroke(0);
  ellipse(0, 0, 60, 60);
  
}

//function to draw the ship
void drawShip() {
  fill (#8D9090);
  ellipse(50, 50, 20, 70);
  fill(0, 0, 0);
  rect(40, 75, 20, 20);
  ellipse (50, 60, 3, 3);
  ellipse (50, 50, 3, 3);
  ellipse( 50, 40, 3, 3);
  fill(#F24222);
  rect(40, 95, 20, 300);
  
  
}




//the draw function - which will loop
void draw() {
  
  
  background(#0B1E36);
  fill(60, 185, 134);
  ellipse (150, 80, 15, 15);
  fill(112, 145, 170);
  ellipse (300, 150, 20, 20);
  fill(66, 87, 216);
  ellipse (60, 250, 15, 15);
  fill(103, 48, 58);
  ellipse (180, 200, 20, 20);
  fill(152, 222, 78);
  ellipse( 280, 60, 10, 10);
  fill( 147, 11, 222);
  ellipse( 340, 260, 20, 20);
  fill( 170, 150, 112);
  ellipse( 50, 40, 30, 10);
  ellipse (270, 250, 40, 10);
  ellipse (110, 190, 7, 7);
  //draw the planet in an updated position using variables
  pushMatrix();
  translate(tx, ty);
  drawPlanet();
  popMatrix();
  pushMatrix();
  translate(0,Sty);
  drawShip();
  popMatrix();

  //update my variables - either randomly update y or use sin
  tx = tx - 1;
  //ty = ty + int(random(-5, 5));
  ty = 100 + int(30*sin(tx/400.0*6*PI)); Sty = Sty-1;
}